
//-----横表图片-------------------------------------------------
 HELPERLOGONAME="layer.gif";
 HELPERLOGO="../../images/"+HELPERLOGONAME;         //帮助按钮
 HELPERLOGO1="../images/"+HELPERLOGONAME;       
 
 
 GOIMAGEMouseOverNAME="go02.gif";
 GOIMAGEMouseOutNAME="go01.gif";
 GOIMAGEMouseOver="../../images/"+GOIMAGEMouseOverNAME;    //GO按钮状态1
 GOIMAGEMouseOut="../../images/"+GOIMAGEMouseOutNAME;     //GO按钮状态2
 GOIMAGEMouseOver1="../images/"+GOIMAGEMouseOverNAME;
 GOIMAGEMouseOut1="../images/"+GOIMAGEMouseOutNAME;


 FIRSTPAGEOverNAME="buttob_01.gif";
 FIRSTPAGEOutNAME="buttoa_01.gif";
 FIRSTPAGEOver="../../images/"+FIRSTPAGEOverNAME; //第一页按钮状态1
 FIRSTPAGEOut="../../images/"+FIRSTPAGEOutNAME; //第一页按钮状态2
 FIRSTPAGEOver1="../images/"+FIRSTPAGEOverNAME;
 FIRSTPAGEOut1="../images/"+FIRSTPAGEOutNAME;
 
 
 LASTPAGEOverNAME="buttob_02.gif";
 LASTPAGEOutNAME="buttoa_02.gif";
 LASTPAGEOver="../../images/"+LASTPAGEOverNAME; //上页按钮状态1
 LASTPAGEOut="../../images/"+LASTPAGEOutNAME; //上页按钮状态2
 LASTPAGEOver1="../images/"+LASTPAGEOverNAME;
 LASTPAGEOut1="../images/"+LASTPAGEOutNAME;
 
 NEXTPAGEOverNAME="buttob_03.gif";
 NEXTPAGEOutNAME="buttoa_03.gif";
 NEXTPAGEOver="../../images/"+NEXTPAGEOverNAME; //下页按钮状态1
 NEXTPAGEOut="../../images/"+NEXTPAGEOutNAME; //下页按钮状态2
 NEXTPAGEOver1="../images/"+NEXTPAGEOverNAME;
 NEXTPAGEOut1="../images/"+NEXTPAGEOutNAME;
 
 
 LASTESTPAGEOverNAME="buttob_04.gif";
 LASTESTPAGEOutNAME="buttoa_04.gif";
 LASTESTPAGEOver="../../images/"+LASTESTPAGEOverNAME; //最后一页页按钮状态1
 LASTESTPAGEOut="../../images/"+LASTESTPAGEOutNAME; //最后一页按钮状态2
 LASTESTPAGEOver1="../images/"+LASTESTPAGEOverNAME;
 LASTESTPAGEOut1="../images/"+LASTESTPAGEOutNAME;
 
 BOTTOMIMAGE="";                       //底部图片
//--------------------------------------------------------------
ADDOut="../../images/lb_1.gif";                             //添加按钮状态1
ADDOver="../../images/la_1.gif";                            //添加按钮状态2
UPDATEOut="../../images/lb_4.gif";                          //修改按钮状态1
UPDATEOver="../../images/la_4.gif";                         //修改按钮状态2
DELOut="../../images/lb_2.gif";                             //删除按钮状态1
DELOver="../../images/la_2.gif";                            //删除按钮状态2
CURRENTMEMOOut="../../images/lc_7.gif";                     //今日提醒按钮状态1
CURRENTMEMOOver="../../images/la_7.gif";                    //今日提醒按钮状态2
MEMOQUERYOut="../../images/lc_8.gif";                       //备忘查询按钮状态1
MEMOQUERYOver="../../images/la_8.gif";                      //备忘查询按钮状态2
QUERYOut="../../images/lb_3.gif";                           //查询按钮状态1
QUERYOver="../../images/la_3.gif";                          //查询按钮状态2
RIGHTOut="../../images/lc_9.gif";                           //权限按钮状态1
RIGHTOver="../../images/la_9.gif";                          //权限按钮状态2
AUDITOut="../../images/lc_10.gif";                          //审核按钮状态1
AUDITOver="../../images/la_10.gif";                         //审核按钮状态2
EXPORTOut="../../images/lc_11.gif";                         //导出按钮状态1
EXPORTOver="../../images/la_11.gif";                        //导出按钮状态2
NIGAOOut1="../images/lc_12.gif";                            //拟稿按钮状态1
NIGAOOver1="../images/la_12.gif";                           //拟稿按钮状态2
STOPOut1="../images/lc_13.gif";                             //终止按钮状态1
STOPOver1="../images/la_13.gif";                            //终止按钮状态2
QUERYOut1="../images/lc_14.gif";                            //查询按钮状态1
QUERYOver1="../images/la_14.gif";                           //查询按钮状态2
STOPQUERYOut1="../images/lc_15.gif";                        //取消查询按钮状态1
STOPQUERYOver1="../images/la_15.gif";                       //取消查询按钮状态2
GETBACKOut1="../images/lc_16.gif";                          //收回按钮状态1
GETBACKOver1="../images/la_16.gif";                         //收回按钮状态2
CUIBANOut1="../images/lc_17.gif";                           //催办按钮状态1
CUIBANOver1="../images/la_17.gif";                          //催办按钮状态2
ZHUANFAWENOut1="../images/lc_18.gif";                       //转发文按钮状态1
ZHUANFAWENOver1="../images/la_18.gif";                      //转发文按钮状态2
STOPPROCCESSOut="../../images/lc_19.gif";                   //结束按钮状态1
STOPPROCCESSOver="../../images/la_19.gif";                  //结束按钮状态2
ADDTOOut="../../images/lc_20.gif";                          //添加到按钮状态1
ADDTOOver="../../images/la_20.gif";                         //添加到按钮状态2
SETPWOut="../../images/lc_21.gif";                          //设置密码按钮状态1
SETPWOver="../../images/la_21.gif";                         //设置密码按钮状态2
LOCKOut="../../images/lc_22.gif";                           //锁定按钮状态1
LOCKOver="../../images/la_22.gif";                          //锁定按钮状态2
UNLOCKOut="../../images/lc_23.gif";                         //解锁按钮状态1
UNLOCKOver="../../images/la_23.gif";                        //解锁按钮状态2

TITLESHOW="images/titleshow.gif"; //标题显示按钮
TITLEHIDDEN="images/titlehidden.gif";//标题隐藏
NAVBARSHOW="images/navbarshow.gif";//qq条显示
NAVBARHIDDEN="images/navbarhidden.gif";//qq条隐藏

GOBACKOutNAME="lb_5.gif";
GOBACKOverNAME="la_5.gif";
GOBACKOut="../../images/"+GOBACKOutNAME;                          //返回按钮状态1
GOBACKOver="../../images/"+GOBACKOverNAME;                         //返回按钮状态2
GOBACKOut1="../images/"+GOBACKOutNAME;
GOBACKOver1="../images/"+GOBACKOverNAME;  

LISTOut="../../images/lb_6.gif";                            //列表按钮状态1
LISTOver="../../images/la_6.gif";                           //列表按钮状态2

//BY CJH
TASKADD="../../images/xiadarenwu.gif";						//下达任务
TASKDEL="../../images/shanchurenwu.gif";					//删除任务
TASKEND="../../images/jieshurenwu.gif";						//结束任务
//================================================================================
//QQ条参数
//================================================================================
NAVBARWIDTH=115;
//===============================================================================
//getStrAllocateLen - get string's length allocated in database
//===============================================================================
function getStrAllocateLen(str){
	var iLen=0;
	var iUnicode;
	
	for(i=0;i<str.length;i++){
		iUnicode=str.charCodeAt(i);
		if (iUnicode<=128){				//英文字符
			iLen+=1;
		}else{
			if (iUnicode>128 && iUnicode<=255){
				iLen+=2;
			}else{
				if (iUnicode>=4112){	//中文字符
					iLen+=2;
				}else{
					iLen+=1;			//其他字符
				}
			}
		}
	}
	return(iLen);
}

//===============================================================================
//openWindow - 
//===============================================================================
function openWindow(url, w, h,n)
{
	var options = "width=" + w + ",height=" + h + ",";
	options += "resizable=yes,scrollbars=yes,status=yes,";
	options += "location=no,menubar=no,toolbar=no,directories=no,top=10,left=119";
	if(n=="")
	{
		var date=new Date();
		n=date.getSeconds();
	}
	n=n+"ab";	
	var newWin=window.open(url,n, options);
	newWin.focus();
}
//===============================================================================
//validatePageNum - validate if the string inputed is a validatePageNum
//===============================================================================
function chartoint(num){
	var mask = '0123456789';
	return mask.indexOf(num);
}
function validatePageNum(obj,pageCount)
{     
     if(isNaN(obj.value))
     {
           alert("您输入了无效页码，请输入数字！");
           obj.value="";
           return false;
     }
     else
     {  
        var str=obj.value;
        var intvalue=0;
		for(var i=0;i<str.length;i++)
		{
			if(chartoint(str.substring(i,i+1))==-1)
			{
				alert("您输入的页码不正确，请输入整数！");
				obj.value="";
	                 return false;
			}
			intvalue = intvalue*10+chartoint(str.substring(i,i+1));
   			if((intvalue>pageCount)||(intvalue<1))
   			{
			         alert("您输入的页码超出可取范围，请重新输入！");
			         obj.value="";
			         return false;
			}
		}
		return true;
	}
	
}
//===============================================================================
//validateInputString - validate if the string inputed contain the invalid chat
//===============================================================================
function validateInputString(strInput){
	if (typeof(strInput)!="string"){
		return(false);
	}
	var i;
	var iCode;
	for (i=0;i<strInput.length;i++){
		iCode=strInput.charCodeAt(i);
		if (iCode!=95){		//	char _
			if (iCode<48 || iCode>122 || (iCode>57 && iCode<65) || (iCode>90 && iCode<97) ){
				return(false);
			}
		}
	}
	return(true);
}

//===============================================================================
//replaceString - in strSource string,search the strFind string and replace with strReplace string 
//===============================================================================
function replaceString(strSource,strFind,strReplace){
	var pos = 0
	var srcLen
	var fndLen
	var repLen
	var strRtn=""
	
	if (typeof(strSource)!='string' || typeof(strFind)!='string' || typeof(strReplace)!='string' ){
		reportError(L_errFuncParaTypeMissMatch_ErrMsg,"replaceString")
		return -1;
	}
	srcLen = strSource.length;
	fndLen = strFind.length;
	repLen = strReplace.length;
	if ( srcLen==0 || srcLen<fndLen || fndLen==0 )
		return strSource;
	pos=strSource.indexOf(strFind,0);
	while ( pos!=-1){
		strRtn += strSource.substr(0,pos);
		strRtn += strReplace;
		strSource=strSource.substr(pos+fndLen);
		pos=strSource.indexOf(strFind,0);
	}
	strRtn+=strSource;
	return strRtn;
}

// Valiate a string that can present a date
// Correct format is 1999/1/31 or 1999-1-13
function isDateStr(sDate)
{
	var aDate = sDate.split('-');
	if(aDate.length == 3 )
	{
		if(isDate(aDate[0], aDate[1], aDate[2])) return(true);
		return(false);
	}
	aDate = sDate.split('/');
	if(aDate.length == 3 )
	{
		if(isDate(aDate[0], aDate[1], aDate[2])) return(true);
		return(false);
	}
	return(false);
}

//===============================================================================
//isDate - check if strYear,strMonth and strDay can combine to date
//===============================================================================
function isDate(strYear,strMonth,strDay){
	if (typeof(strYear)!='string' || typeof(strMonth)!='string' || typeof(strDay)!='string'){
		reportError(L_errFuncParaTypeMissMatch_ErrMsg,"isDate")
		return false;
	}
	var iYear = strYear * 1
	var iMonth = strMonth * 1
	var iDay = strDay * 1
	if (isNaN(iYear) || isNaN(iMonth) || isNaN(iDay)){
		return false;
	}
	if (iYear<1000 || iYear>9999)
		return false;
	if (iMonth<1 || iMonth>12)
		return false;
	if (iDay<1 || iDay>31)
		return false;
	var strDate = iMonth+"/"+iDay+"/"+iYear
	var objDate = new Date(strDate)
	iYear = objDate.getFullYear()
	iMonth = objDate.getMonth()+1
	iDay = objDate.getDate()
	if (strDate!=(iMonth+"/"+iDay+"/"+iYear))
		return false;
	return true;	
}

//===============================================================================
//isTime - check if strHour,strMinute and strSecond can combine to time
//===============================================================================
function isTime(strHour,strMinute,strSecond){
	if (typeof(strHour)!='string' || typeof(strMinute)!='string' || typeof(strSecond)!='string'){
		reportError(L_errFuncParaTypeMissMatch_ErrMsg,"isDate")
		return false;
	}
	if (strHour=="" && strMinute=="" && strSecond==""){
		return true;
	}
	var iHour = strHour * 1
	var iMinute = strMinute * 1
	var iSecond = strSecond * 1
	if (isNaN(iHour) || isNaN(iMinute) || isNaN(iSecond)){
		return false;
	}
	if (iHour<0 || iHour>23) return false;
	if (iMinute<0 || iMinute>59) return false;
	if (iSecond<0 || iSecond>59) return false;
	return true;
}

// To clear starting & ending space in a string object
function trimStr(sVal)
{
	var iPos;
	//clear starting space
	while(true)
	{
		iPos = sVal.indexOf(' ');
		if(iPos == -1) break;
		if(iPos > 0) break;
		sVal = sVal.slice(1);
	}
	//clear ending space
	while(true)
	{
		iPos = sVal.lastIndexOf(' ');
		if(iPos == -1) break;
		if(iPos < sVal.length-1) break;
		sVal = sVal.slice(0, iPos);
	}
	return(sVal);
}

//鼠标移入,移出变换图标
function MM_findObj(n, d) 
{
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage()
{
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore()
{
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

//显示或隐藏左侧
function changeNavbarSize(navbarobject){
	if(top.root.cols!='0,*'){
		navbarobject.src=NAVBARHIDDEN;
		top.root.cols='0,*';
		//top.head.rows='0,*,26';
	}else{
	        navbarobject.src=NAVBARSHOW ;
		top.root.cols=''+NAVBARWIDTH+',*';
		//top.head.rows='93,*,26';
	}
}
//显示或隐藏左侧
function changeTitleSize(titleobject){
	if(top.head.rows!='0,*,20'){
		titleobject.src=TITLEHIDDEN;
		top.head.rows='0,*,20';
	}else{
	        titleobject.src=TITLESHOW;
		top.head.rows='70,*,20';
	}
}
//显示或隐藏
function turnit(ss)
{
	
    if (ss.style.visibility=="hidden") 
    {	
        ss.style.visibility="visible";
    }else{
        ss.style.visibility="hidden"; 
    }
}

//判断提醒，开始和结束时间的顺序是否正确

function checkTimeSequence(wakeStr,startStr,endStr)
{
	var wake = wakeStr.split(' ');
	var start = startStr.split(' ');
	var end = endStr.split(' ');
	var wakeTime,startTime,endTime;
	if(wake.length==2)
	{
		var aDate = wake[0].split('-');
		var aTime = wake[1].split(':');
		wakeTime = aDate[0]*100000000+aDate[1]*1000000+aDate[2]*10000+aTime[0]*100+aTime[1]*1;
	}
	if(wake.length==1)
	{
		var aDate = wake[0].split('-');
		wakeTime = aDate[0]*100000000+aDate[1]*1000000+aDate[2]*10000;
	}
	if(start.length==2)
	{
		var aDate = start[0].split('-');
		var aTime = start[1].split(':');
		startTime = aDate[0]*100000000+aDate[1]*1000000+aDate[2]*10000+aTime[0]*100+aTime[1]*1;
	}
	if(start.length==1)
	{
		var aDate = start[0].split('-');
		startTime = aDate[0]*100000000+aDate[1]*1000000+aDate[2]*10000;
	}
	if(end.length==2)
	{
		var aDate = end[0].split('-');
		var aTime = end[1].split(':');
		endTime = aDate[0]*100000000+aDate[1]*1000000+aDate[2]*10000+aTime[0]*100+aTime[1]*1;
	}
	if(end.length==1)
	{
		var aDate = end[0].split('-');
		endTime = aDate[0]*100000000+aDate[1]*1000000+aDate[2]*10000;
	}
	
	if(startTime>endTime)
		return false;
	else
		return true;
}

function checkPage(pageNum,pageNow,pageCount)
{
	
	if (pageCount==0)//无内容
	{
		alert("没有内容显示！");
		return false;
	}
	else
	{
		if ((pageCount==1)&&(pageNow==1))//只有一页的情况，警告只有一页
		{
			if ((pageNum==1)&&(pageNum!=""))
			{
				alert("只有一页！");
				return false;
			}
			if (pageNum==0)
			{
				alert("只有一页！");
				return false;
			}
			if (pageNum==2)
			{
				alert("只有一页！");
				return false;
			}
		}
		else//多页情况
		{
			//如果输入页要大于总页数且输入页不等于1且当前页等于总页数时，说明已到最后一页
			if ((pageNum>=pageCount)&&(pageNum!=1)&&(pageCount==pageNow)&&(pageNum!=""))
			{
				alert("已经是最后一页了！");
				return false;
			}
			//如果输入页小于等于当前页且输入页不等于1且当前页等于1，说明已到达第一页
			if ((pageNum<=pageNow)&&(pageNum!=1)&&(pageNow==1))
			{
				alert("已经是第一页了！");
				return false;
			}
			//如果输入页小于等于当前页且输入页等于1且当前页等于1，说明已到达第一页
			if ((pageNum<=pageNow)&&(pageNum==1)&&(pageNow==1))
			{
				alert("已经是第一页了！");
				return false;
			}
		}
	}
	return true;
}

function checkStartTimeAndEndTime(startStr,endStr)
{
	var start = startStr.split(' ');
	var end = endStr.split(' ');
	var startTime,endTime;
	if(start.length==2)
	{
		var aDate = start[0].split('-');
		var aTime = start[1].split(':');
		startTime = aDate[0]*100000000+aDate[1]*1000000+aDate[2]*10000+aTime[0]*100+aTime[1]*1;
	}
	if(start.length==1)
	{
		var aDate = start[0].split('-');
		startTime = aDate[0]*100000000+aDate[1]*1000000+aDate[2]*10000;
	}
	if(end.length==2)
	{
		var aDate = end[0].split('-');
		var aTime = end[1].split(':');
		endTime = aDate[0]*100000000+aDate[1]*1000000+aDate[2]*10000+aTime[0]*100+aTime[1]*1;
	}
	if(end.length==1)
	{
		var aDate = end[0].split('-');
		endTime = aDate[0]*100000000+aDate[1]*1000000+aDate[2]*10000;
	}
	
	if(startTime>endTime)
		return true;
	else
		return false;
}

function update(servicename){
  if(confirm("准备操作您选择的记录，是否继续？"))
  {
	for (var i=0;i<dataform.elements.length;i++) 
	{
		if (dataform.elements[i].name=="ids")
			if (dataform.elements[i].checked==true)
			 {
			    dataform.jsprequest.value=servicename;			   
			    dataform.action="viewcontrol.jsp"; 
			    dataform.submit();return;
			}
	}
	alert ("请选择待操作的项!");
	return;
  }else return;
}
function Edit(servicename){
	dataform.jsprequest.value=servicename;
	dataform.action="viewcontrol.jsp"; 
	dataform.submit();
	return;
}
function checkuserList(value,text,obj)
{
	var flag=false;
	//查找是否存在相同的部门或者人员
	for (var j=0;j<=obj.options.length-1;j++)
	{
		if (value==obj.options[j].value)
		{
			alert("你已经选择了"+text+"！");
			flag=true;
			break;
		}
		else 
		{continue;}
	}
  
	if (flag)
	{
		return false;
	}
	if (flag==false)
	{
		return true;
	}
}
function openDialogAndAlert(url,w,h,showModal){
	for (var i=0;i<dataform.elements.length;i++){
		if (dataform.elements[i].name=="ids"){
			if (dataform.elements[i].checked==true){
				url+="&id="+dataform.elements[i].value;
				if(showModal){
					perty ="dialogHeight:"+h+"px;dialogWidth:"+w+"px;dialogHide:yes;scroll:no;help:no;status:no;center:yes";
					window.showModalDialog(url,"",perty);
				}else{
					var options = "width=" + w + ",height=" + h + ",";
					options += "resizable=no,scrollbars=no,status=no,";
					options += "location=no,menubar=no,toolbar=no,directories=no,top=10,left=119";
					var newWin=window.open(url,"", options);
					newWin.focus();
				}
				return;
			}
		}
	}
	alert ("请选择待操作的项!");
}

function openDialog(url,w,h){
	perty ="dialogHeight:"+h+"px;dialogWidth:"+w+"px;dialogHide:yes;scroll:no;help:no;status:no;center:yes";
	var v=window.showModalDialog(url,"",perty);
	return v;
}

function getPerson(cmd,selectObj)
{
	
	if(cmd=='add')
	{
		var para = "addressParaStr=1,-1,true,true,true&selectUser=true&selectOrg=false&selectGroup=false&showMode=1";
		var userInfoes=window.showModalDialog("addressbook.jsp?"+para+"");
		if(userInfoes==null || userInfoes=="") return;
		var users=userInfoes.split(";");
		for(var i=0;i<users.length-1;i++)
		{
			var infoes=users[i].split(",");
			var oOption = document.createElement("OPTION");
			if (checkuserList(infoes[1],infoes[2],selectObj))
			{
				oOption.text = infoes[2];
				oOption.value = infoes[1];
				selectObj.add(oOption);
			}	
		}
	}
	if(cmd=='remove')
	{
		for(var i=0;i<selectObj.options.length;i++)
		{
			if (selectObj.options(i).selected==true)
				selectObj.options.remove(i--);
		}
	}
}
function getTime(obj)
{
	str = window.showModalDialog("/oa/pubfunc/calender.html","","dialogHeight:333px;dialogLeft:(screen.width/2-195/2)px;dialogTop:(screen.height/2-195/2)px;dialogWidth:195px;center:yes;resizable:no;status:no;");
	obj.value= str;
	if(obj.value=="undefined")
		obj.value="";	
}
function transmit(jspPageName)//ge ren tong xunlu
 {
   var count=0;
   if(dataform.ids==null)
   {
     alert("当前无记录！")
     return;
   }
   for (var i=0;i<dataform.ids.length;i++) 
   {
     if (dataform.ids[i].checked==true)
     {
       count=count+1;
       if(count>1)
       {
          alert("请选择唯一的转发记录！")
          return;
       }
     }
   }
   for (var i=0;i<dataform.ids.length;i++) 
   {
     if (dataform.ids[i].checked==true)
     {    
       var v=jspPageName+"?id="+dataform.ids[i].value
       window.open(v,'webpage','toolbar=no,directories=no,menubar=no,resizable=yes,height=450,width=850,top=130,left=120');
       
       return;
     }
   }
   if (dataform.ids.checked==true)
   {
     var v=jspPageName+"?id="+dataform.ids.value
     window.open(v,'webpage','toolbar=no,directories=no,menubar=no,resizable=yes,height=450,width=850,top=130,left=120');	
     return;
   }
   alert("请选择要转发的项！");  
 }
 function go(form,sort,by){
	form.sort.value=sort;
	form.by.value=by;
	form.action="";
	form.target="";
	form.submit();
 }
